package design.pattern.Iterator;

public class ListImpl implements List {

    Object[] objects = null;
    volatile int i  = 0;

    public ListImpl(int size) {
        this.objects = new Object[size];
    }

    @Override
    public Object add(Object o) {
        objects[i] = o;
        i++;
        return o;
    }

    @Override
    public Object get(int o) {
        return this.objects[o];
    }

    @Override
    public Object remove(Object o) {
        return null;
    }

    @Override
    public Iterator iterator() {
        return new IteratorImpl(this);
    }

    @Override
    public int size() {
        return this.objects.length;
    }
}
